package itdep.common.util;

import org.springframework.test.util.ReflectionTestUtils;
import static org.testng.Assert.*;

import java.util.Map;

/**
 * @author Ivan Khalopik
 * @version $Revision: 4 $ $Date: 2010-06-10 13:13:16 +0000 (Thu, 10 Jun 2010) $
 */
public class TestUtils {

	public static void fillEntity(final Object entity, final Map<String, Object> values) {
		for (Map.Entry<String, Object> entry : values.entrySet()) {
			ReflectionTestUtils.invokeSetterMethod(entity, entry.getKey(), entry.getValue());
		}
	}

	public static void assertEntity(final Object entity, final Map<String, Object> values) {
		for (Map.Entry<String, Object> entry : values.entrySet()) {
			final Object value = ReflectionTestUtils.invokeGetterMethod(entity, entry.getKey());
			assertEquals(value, entry.getValue());
		}
	}

}
